import logging
import os


class BaseConfig:
    UPLOAD_FOLDER = os.path.abspath('resources')

    # JSON配置
    JSON_AS_ASCII = False

    # 会话密钥配置
    SECRET_KEY = os.getenv('SECRET_KEY', 'T-flask')

    # 默认日志等级
    LOG_LEVEL = logging.WARN

    # mysql 数据库的配置信息
    SQLALCHEMY_DATABASE_URI = 'sqlite:///database.db'
    SQLALCHEMY_TRACK_MODIFICATIONS = False


class TestingConfig(BaseConfig):
    """ 测试配置 """
    ...


class DevelopmentConfig(BaseConfig):
    """ 开发配置 """
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    SQLALCHEMY_ECHO = False


class ProductionConfig(BaseConfig):
    """生成环境配置"""
    LOG_LEVEL = logging.ERROR

    SQLALCHEMY_ECHO = False
    SQLALCHEMY_POOL_RECYCLE = 8


config = {
    'development': DevelopmentConfig,
    'testing': TestingConfig,
    'production': ProductionConfig
}
